fix: accumulate WebSocketResponsesRequest as responses streaming (#3001)#3020
fix: accumulate WebSocketResponsesRequest as responses streaming (#3001)#3020thiscantbeserious wants to merge 1 commit intomaximhq:mainfrom
Conversation
…imhq#3001) ProcessStreamingResponse in framework/streaming/accumulator.go classified only ResponsesStreamRequest as responses streaming. Any WebSocketResponsesRequest chunk fell through to the default error return, silently dropping token usage and output accumulation for every native-WS Responses request. The same omission existed in plugins/logging/utils.go convertToProcessedStreamResponse, where the request-type switch assigned StreamTypeResponses only for ResponsesStreamRequest, leaving WebSocketResponsesRequest to fall through to the default StreamTypeChat branch and produce incorrect stream-type metadata in log entries. Both locations now treat WebSocketResponsesRequest identically to ResponsesStreamRequest. WebSocketResponsesRequest carries the same BifrostResponsesStreamResponse chunk shape, so no downstream handler changes are required. Two regression tests are added to framework/streaming/accumulator_test.go: - TestWebSocketResponsesRequestAccumulatedAsResponsesStreaming verifies that a full WS chunk sequence produces a non-nil ProcessedStreamResponse with token usage populated. - TestWebSocketResponsesRequestVsResponsesStreamRequestParity runs both request types through ProcessStreamingResponse and asserts neither returns an error. Closes maximhq#3001
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The WebSocketResponsesRequest classification in ProcessStreamingResponse was extracted to maximhq/bifrost PR maximhq#3020 (fixes issue maximhq#3001). Removing the duplicate from this feature branch to avoid a merge conflict and keep the feature branch focused on OAuth passthrough concerns. Extraction commit: 606f47b
|
Superseded by #3018 (merged 2026-04-24), which bundles the fix for this issue and several other native WS reliability bugs. Closing this draft as redundant. |
Summary
Token counts and output data were silently lost for every native-WS Responses request because the accumulator rejected those chunks with an error that callers discarded without logging.
Root cause:
ProcessStreamingResponseinframework/streaming/accumulator.gosetisResponsesStreamingbased only onResponsesStreamRequest. AWebSocketResponsesRequestchunk fell through to the final error return (request type missing/invalid for accumulator). The same gap existed inplugins/logging/utils.goconvertToProcessedStreamResponse, where the request-type switch fell through to the defaultStreamTypeChatbranch for WS requests.WebSocketResponsesRequestcarries an identicalBifrostResponsesStreamResponsechunk shape toResponsesStreamRequest, so the existingprocessResponsesStreamingResponsepath handles it correctly with no further changes needed.Changes
framework/streaming/accumulator.go: add|| requestType == schemas.WebSocketResponsesRequestto theisResponsesStreamingguard inProcessStreamingResponse.plugins/logging/utils.go: extend theResponsesStreamRequestcase in theconvertToProcessedStreamResponseswitch to also matchWebSocketResponsesRequest.framework/streaming/accumulator_test.go: two new regression tests covering the WS path throughProcessStreamingResponse.Type of change
Affected areas
How to test
Both new tests (
TestWebSocketResponsesRequestAccumulatedAsResponsesStreamingandTestWebSocketResponsesRequestVsResponsesStreamRequestParity) must pass. The second test exercises the exact pre-fix code path that returned the silent error.Breaking changes
No.
Related
This fix was discovered while working on PR #2775 (openai-oauth-passthrough). The PR branch contains the original version of this fix, which has been extracted here as a focused upstream contribution.
Closes #3001